from django.db import models
from django.contrib.auth.models import AbstractUser,BaseUserManager,PermissionsMixin,User
# Create your models here.

# class userinfo(models.Model)
# class Userinfo(models.Model):
#     user = models.OneToOneField(User,on_delete=models.CASCADE,related_name='profile')
#     name=models.CharField(max_length=32,verbose_name="姓名",default='null')
#     Gender=models.CharField(max_length=16,default='null',verbose_name="性别")
# class nn(models.Model):
#     Name=models.CharField(max_length=32,verbose_name="姓名",default='null')
class Userinfo(AbstractUser):
    Name=models.CharField(max_length=32,verbose_name="姓名",default='null')
    Gender_type=(
        ("1",'男性'),
        ('2','女性')
        )
    Gender=models.CharField(max_length=2,null=True,blank=True,verbose_name="性别",choices=Gender_type)
    Phone=models.CharField(max_length=15,default='null',verbose_name='电话号码')
    # phone=models.PhoneNumberField(defalut='null',verbose_name='电话号码')
    WX_id=models.CharField(max_length=32,default='null',verbose_name='微信号')
    Avatr=models.ImageField(upload_to='avatr',default='null')
    Introduction=models.CharField(max_length=648,default='无',verbose_name='介绍')
    location_type=(("1","丰台校区"),("2","海淀校区"),("3","海南校区"))
    location=models.CharField(max_length=4,default='无',verbose_name='位置',choices=location_type)
    
class UserGoods(models.Model):
    username = models.ForeignKey(Userinfo, on_delete=models.CASCADE,related_name='goods')
    name=models.CharField( max_length=50,default='无')
    describe=models.CharField(max_length=648,default='无')
    image=models.ImageField(upload_to='goodsimg' ,default='null')
    countnum=models.IntegerField(default=1)
    price=models.FloatField(default=0)
    goods_type=(("sell","sell"),("buy","buy"))
    goodtype=models.CharField(max_length=4,null=True,blank=True,choices=goods_type)
    good_status=(("visible","visible"),("invisible","invisible"))
    goodstatus=models.CharField(max_length=10,null=True,blank=True,choices=good_status)
class Image(models.Model):
    # 图片
    img = models.ImageField(upload_to='img',blank=True, null=True, verbose_name='图片')
    img_name=models.CharField(max_length=32,default='null')
    # 创建时间

        